package com.liugui.basicsgrammar2;

/**
 * @ClassName: SumOfEvenFor
 * @Author: liugui
 * @Date: 2020-10-18 13:55
 **/
public class SumOfEvenFor {
    public static void main(String[] args) {
        //实现计算 1-1000 中所有偶数的和
        //使用for循环
        int num = 0;
        for (int i = 1; i <= 1000; i++) {
            if ( 0 == i % 2){
                num += i;
            }
        }
        System.out.println( num );//250500
    }
}
